package com.ios.palette.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.CollectionOfElements;

@Entity
@Table
public class Status implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	private Long id;
	private String createAt;
	@CollectionOfElements
	private Set<String> pics = new HashSet<>();
	@CollectionOfElements
	private Set<String> tags = new HashSet<>();
	private String title;
	private String artDesc;
	@Column(columnDefinition = "int default 0")
	private int likeCount = 0;
	@Column(columnDefinition = "int default 0")
	private int collectionCount = 0;
	@Column(columnDefinition = "int default 0")
	private int hotCount = 0;
	@ManyToOne(targetEntity = User.class)
	@JoinColumn(name = "user_id", referencedColumnName = "id")
	private User user;
	@ManyToMany(targetEntity = Status.class)
	@JoinTable(name = "user_status_like", joinColumns = @JoinColumn(name = "status_id", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "liker_id", referencedColumnName = "id") )
	private Set<User> liker = new HashSet<>();
	@OneToMany(fetch = FetchType.EAGER)
	@JoinColumn(name = "status_id", referencedColumnName = "id")
	@Cascade(CascadeType.ALL)
	private Set<Comment> comments = new HashSet<>();

	/**
	 * @return the liker
	 */
	public Set<User> getLiker() {
		return liker;
	}

	/**
	 * @param liker
	 *            the liker to set
	 */
	public void setLiker(Set<User> liker) {
		this.liker = liker;
	}

	public Long getId() {
		return id;
	}

	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * @param user
	 *            the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * @return the comments
	 */
	public Set<Comment> getComments() {
		return comments;
	}

	/**
	 * @param comments
	 *            the comments to set
	 */
	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}

	/**
	 * @return the pics
	 */
	public Set<String> getPics() {
		return pics;
	}

	/**
	 * @param pics
	 *            the pics to set
	 */
	public void setPics(Set<String> pics) {
		this.pics = pics;
	}

	/**
	 * @return the likeCount
	 */
	public int getLikeCount() {
		return likeCount;
	}

	/**
	 * @param likeCount
	 *            the likeCount to set
	 */
	public void setLikeCount(int likeCount) {
		this.likeCount = likeCount;
	}

	/**
	 * @return the collectionCount
	 */
	public int getCollectionCount() {
		return collectionCount;
	}

	/**
	 * @param collectionCount
	 *            the collectionCount to set
	 */
	public void setCollectionCount(int collectionCount) {
		this.collectionCount = collectionCount;
	}

	/**
	 * @return the hotCount
	 */
	public int getHotCount() {
		return hotCount;
	}

	/**
	 * @param hotCount
	 *            the hotCount to set
	 */
	public void setHotCount(int hotCount) {
		this.hotCount = hotCount;
	}

	/**
	 * @return the tags
	 */
	public Set<String> getTags() {
		return tags;
	}

	/**
	 * @param tags
	 *            the tags to set
	 */
	public void setTags(Set<String> tags) {
		this.tags = tags;
	}

	/**
	 * @return the createAt
	 */
	public String getCreateAt() {
		return createAt;
	}

	/**
	 * @param createAt
	 *            the createAt to set
	 */
	public void setCreateAt(String createAt) {
		this.createAt = createAt;
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title
	 *            the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @return the artDesc
	 */
	public String getArtDesc() {
		return artDesc;
	}

	/**
	 * @param artDesc
	 *            the artDesc to set
	 */
	public void setArtDesc(String artDesc) {
		this.artDesc = artDesc;
	}

}
